Refining algebraic data types

نویسنده

  • Andrei Lapets
چکیده

Our purpose is to formalize two potential refinements of single-sorted algebraic data types – subalgebras and algebras which satisfy equivalence relations – by considering their categorical interpretation. We review the usual categorical formalization of singleand multi-sorted algebraic data types as initial algebras, and the correspondence between algebraic data types and endofunctors. We introduce a relation on endofunctors which corresponds to a subtyping relation on algebraic data types, and partially extend this relation to multi-sorted algebras. Finally, we explore how this relation can help us understand single-sorted algebraic data types which satisfy equivalence relations. 1 Algebraic Data Types as Initial Algebras In programming languages with type systems, a type usually represents a family of values, such as the space of 32-bit integers: Int32 ∼= Z/232Z. Some programming languages (popular examples include Haskell [Je99] and ML [MTHM97]) have type systems which allow a programmer to define her own families of values by means of a recursion equation. For example, the data type representing inductively constructed binary trees with integer values at the leaves can be defined by the equation IntTree = Int32 ] (IntTree× IntTree). Typically, names must be assigned to the functions which allow the programmer to construct values of a data type. The diagram below illustrates this particular example: Int32 Leaf && M M M M M M M M M M IntTree× IntTree Node uukkkk kkkk kkkk kk IntTree The two functions Leaf : Int32 → IntTree and Node : IntTree × IntTree → IntTree can effectively be viewed as operators in an algebra which has no axioms. Together, they induce an isomorphism ∗[email protected] 1 [Leaf, Node] : Int32 ] (IntTree× IntTree)→ IntTree. In general, if an algebraic data type has k such constructor functions, we will denote them ω1, . . . , ωk. We will call the collection Ω = {ω1, . . . , ωk} the signature of an algebra. Now, if we assume that the collection of types in a hypothetical programming language is a category K, any recursion equation can be converted to an open form to obtain an endofunctor F : K → K. In our example, F is then defined to be F (X) = Int32 ] (X ×X) F (f) = [1Int32, f × f ], where f ∈ K(A,B) for any A,B ∈ Obj(K). Note that if there is a corresponding signature Ω, we can decompose the functor into a disjoint sum of the domains of each of the operators in Ω: F (X) = ⊎ ωi∈Ω Fωi(X), where ∀i, dom(ωi) = Fωi(X). In this case, the operators in Ω induce an arrow [ω1, . . . , ωn] : F (X)→ X. This suggests a definition for an algebra. Definition 1.1 Given an endofunctor F : K → K, an object A ∈ K is an F -algebra if there exists an arrow a : F (A)→ A in K(F (A), A) [Pie91]. We can now see that the object IntTree ∈ Obj(K) is indeed an F -algebra, since there exists an arrow [Leaf, Node] : F (IntTree) → IntTree. The collection of F -algebras forms a category, with homomorphisms between these algebras acting as arrows. Definition 1.2 Given an endofunctor F : K → K and F -algebras A and B, an arrow h ∈ K(A,B) is an F -homomorphism if the following diagram commutes [Pie91]:

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Augmenting Simulated Annealing to Build Interaction Test Suites

Component based software development is prone to unexpected interaction faults. The goal is to test as many potential interactions as is feasible within time and budget constraints. Two combinatorial objects, the orthogonal array and the covering array, can be used to generate test suites that provide a guarantee for coverage of all -sets of component interactions in the case when the testing o...

متن کامل

A Specification for Underground Tank Monitoring System (UTMS) Using Real-Time Process Algebra (RTPA)

87 Abstract— The Real-time process algebra (RTPA) is a set of new mathematic notations for formally describing system architecture, and static and dynamic behaviors. It is recognized that the specification of software behaviors is a threedimensional problem known as: (1) mathematic operation, (2) event/process timing, (3) memory manipulation. RTPA is designed as a coherent, expressive and easy-...

متن کامل

An Incremental Algorithm for Computing Cylindrical Algebraic Decompositions

In this paper, we propose an incremental algorithm for computing cylindrical algebraic decompositions. The algorithm consists of two parts: computing a complex cylindrical tree and refining this complex tree into a cylindrical tree in real space. The incrementality comes from the first part of the algorithm, where a complex cylindrical tree is constructed by refining a previous complex cylindri...

متن کامل

A Framework for Extended Algebraic Data Types

Data Types have Existential Types data Stack a = forall s. Stack s -self (a->s->s) -push (s->s) -pop (s->a) -top (s->Bool) -empty push :: a -> Stack a -> Stack a push x (Stack s push’ pop top empty) = Stack (push’ x s) push’ pop top empty pop :: Stack a -> Stack a pop (Stack s push pop’ top empty) = Stack (pop’ s) push pop’ top empty A Framework for Extended Algebraic Data Types – p.6 Abstract ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2007